package org.csu.petstore_manage.service;

import org.csu.petstore_manage.domain.User;
import org.csu.petstore_manage.persistence.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;

    public List<User> getUsers(){
        return userMapper.getUsers();
    }


    /*
        声明式事务处理
     */
    @Transactional

    public void updateUser(User user){
        userMapper.updateUser(user);
        userMapper.updateProfile(user);
        userMapper.updateSignon(user);
    }

    public void deleteUser(User user){
        userMapper.deleteUser(user);
        userMapper.deleteProfile(user);
        userMapper.deleteSignon(user);
    }
}
